package me.hunche.app.domain;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;

import com.feinno.framework.common.domain.AbstractEntity;



@Entity
@Table(name="t_activity_member")
public class ActivityMember extends AbstractEntity implements Serializable{

	private static final long serialVersionUID = -4147974844565340936L;
	
	/** 预备队员*/
	public final static int TYPE_RESERVE = 0;
	/** 预备队员*/
	public final static int TYPE_REGULAR = 1;
	/** 正式队员*/
	public final static int TYPE_LEADER= 2;
	/** 退出队员*/
	public final static int TYPE_OUT= -1;
	
	public final static int FLAG_TRUE= 1;
	public final static int FLAG_FALSE= 0;
	
	@Id 
    @GeneratedValue(strategy = GenerationType.IDENTITY)
	private Long id;
	private Integer type;

	private Long userId;
	private String nickname;
	public String getNickname() {
		return nickname;
	}
	public void setNickname(String nickname) {
		this.nickname = nickname;
	}


	private String mobile;
	private Long activityId;
	private Long priorityId;
//	private Integer readyFlag;
//	private Integer goneFlag;
	private Date joinTime;
	private Date readyTime;
	private Date goneTime;
	
	//	@ManyToOne
//	@JoinColumn(name = "user_id", referencedColumnName = "user_id")
	@Transient transient private User user;
	
//	@ManyToOne
//	@JoinColumn(name = "activity_id", referencedColumnName = "activity_id")
	@Transient transient private Activity activity;
	
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	
	public Date getJoinTime() {
		return joinTime;
	}
	public void setJoinTime(Date joinTime) {
		this.joinTime = joinTime;
	}
	
	public User getUser() {
		return user;
	}
	public void setUser(User user) {
		this.user = user;
	}
	
	public Activity getActivity() {
		return activity;
	}
	public void setActivity(Activity activity) {
		this.activity = activity;
	}
	public Integer getType() {
		return type;
	}
	
	
	public void setType(Integer type) {
		this.type = type;
	}

	@Transient public boolean isLeader(){
		return (type == TYPE_LEADER);
	}
	
	@Transient public boolean isRegular(){
		return (type == TYPE_REGULAR);
	}
	
	@Transient public boolean isReserve(){
		return (type == TYPE_RESERVE);
	}
	
	@Transient public boolean hasReady(){
		return readyTime !=null;
		
	}
	
	@Transient public boolean hasGone(){
		return goneTime !=null;
	}
	

	public Long getUserId() {
		return userId;
	}
	public void setUserId(Long userId) {
		this.userId = userId;
	}
	public Long getActivityId() {
		return activityId;
	}
	public void setActivityId(Long activityId) {
		this.activityId = activityId;
	}
	public Long getPriorityId() {
		return priorityId;
	}
	public void setPriorityId(Long priorityId) {
		this.priorityId = priorityId;
	}
	
	public Date getReadyTime() {
		return readyTime;
	}
	public void setReadyTime(Date readyTime) {
		this.readyTime = readyTime;
	}
	public Date getGoneTime() {
		return goneTime;
	}
	public void setGoneTime(Date goneTime) {
		this.goneTime = goneTime;
	}
	public String getMobile() {
		return mobile;
	}
	public void setMobile(String mobile) {
		this.mobile = mobile;
	}
	public String toString() {
		return "ActivityMember [id=" + id + ", type=" + type + ", joinTime="
				+ joinTime + ", userId=" + userId + ", user=" + user
				+ ", activity=" + activity + "]";
	}
}
